
* Daniel Berliner & Joachim Wehner
* "Audits for Accountability: Evidence from Municipal By-elections in South Africa"
* The Journal of Politics
* Stata replication do file
* Use together with Berliner-Wehner_SACS.dta
* Stata version 16.1
* Date prepared: May 14, 2021


* Setting primary sampling unit and sampling weights
svyset nqid [pw = random_monthly_wgt]


**********************************************************
*** Table 2: Audits and mayoral approval (survey data) ***
**********************************************************

set more off

* With controls
svy: regress doingjob_mayor post##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) replace
lincom 1.post + audit_change_3#1.post
lincom 1.post + (-1)*audit_change_3#1.post

* Separate pos and neg change
svy: regress doingjob_mayor post##c.audit_change_pos post##c.audit_change_neg date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) append
lincom 1.post + audit_change_pos#1.post
lincom 1.post + audit_change_neg#1.post

* Muni FE
svy: regress doingjob_mayor post##c.audit_change_3 date date2 date3 i.eano_3digit i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) append
lincom 1.post + audit_change_3#1.post
lincom 1.post + (-1)*audit_change_3#1.post

* Date linear
svy: regress doingjob_mayor post##c.audit_change_3 date i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) append
lincom 1.post + audit_change_3#1.post
lincom 1.post + (-1)*audit_change_3#1.post

* Logit for very bad mayor
svy: logit mayor_verybad post##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) append
lincom 1.post + audit_change_3#1.post
lincom 1.post + (-1)*audit_change_3#1.post

* Ordered
svy: ologit doingjob_mayor post##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) append
lincom 1.post + audit_change_3#1.post
lincom 1.post + (-1)*audit_change_3#1.post

* Placebo (national government approval)
svy: regress doingjob_natgov post##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_2.out, nolabel bdec(3) rdec(3) append
lincom 1.post + audit_change_3#1.post
lincom 1.post + (-1)*audit_change_3#1.post


*******************************************************
*** Table A18: Different time windows (survey data) ***
*******************************************************

set more off

* Split by weeks in separate models with varying windows
svy: regress doingjob_mayor postweekwindow_1##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_A16.out, nolabel bdec(3) rdec(3) replace
lincom 1.postweekwindow_1 + audit_change_3#1.postweekwindow_1
lincom 1.postweekwindow_1 + (-1)*audit_change_3#1.postweekwindow_1

svy: regress doingjob_mayor postweekwindow_2##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_A16.out, nolabel bdec(3) rdec(3) append
lincom 1.postweekwindow_2 + audit_change_3#1.postweekwindow_2
lincom 1.postweekwindow_2 + (-1)*audit_change_3#1.postweekwindow_2

svy: regress doingjob_mayor postweekwindow_3##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_A16.out, nolabel bdec(3) rdec(3) append
lincom 1.postweekwindow_3 + audit_change_3#1.postweekwindow_3
lincom 1.postweekwindow_3 + (-1)*audit_change_3#1.postweekwindow_3

svy: regress doingjob_mayor postweekwindow_4##c.audit_change_3 date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 if drop_mayorchange==0 
*outreg2 using table_A16.out, nolabel bdec(3) rdec(3) append
lincom 1.postweekwindow_4 + audit_change_3#1.postweekwindow_4
lincom 1.postweekwindow_4 + (-1)*audit_change_3#1.postweekwindow_4


********************************************************************************
*** Table A19: Respondents who have heard of municipal audits (survey data)n ***
********************************************************************************

set more off

* Claim to have heard of audits or problematic spending
* With controls
svy: regress heard post date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 
*outreg2 using table_A17.out, nolabel bdec(3) rdec(3) replace

* Muni FE
svy: regress heard post date date2 date3 i.eano_3digit i.met_ur age1 edu income1 income_noanswer unemp female i.race1 
*outreg2 using table_A17.out, nolabel bdec(3) rdec(3) append

* Date linear
svy: regress heard post date i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 
*outreg2 using table_A17.out, nolabel bdec(3) rdec(3) append

* Logit
svy: logit heard post date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1
*outreg2 using table_A17.out, nolabel bdec(3) rdec(3) append


*********************************************************************************************************************
*** Table A20: Respondents who say corruption and financial mismanagement information is very important in voting ***
*********************************************************************************************************************

set more off

* With controls - corr_vimp
svy: regress corr_vimp post date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 
*outreg2 using table_A18.out, nolabel bdec(3) rdec(3) replace

* Muni FE - corr_vimp
svy: regress corr_vimp post date date2 date3 i.eano_3digit i.met_ur age1 edu income1 income_noanswer unemp female i.race1 
*outreg2 using table_A18.out, nolabel bdec(3) rdec(3) append

* Date linear - corr_vimp
svy: regress corr_vimp post date i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1 
*outreg2 using table_A18.out, nolabel bdec(3) rdec(3) append

* Logit - corr_vimp
svy: logit corr_vimp post date date2 date3 i.prov i.met_ur age1 edu income1 income_noanswer unemp female i.race1
*outreg2 using table_A18.out, nolabel bdec(3) rdec(3) append

sum heard corr_vimp if drop_mayorchange==0


***************************************************
*** Table A22: Summary statistics (survey data) ***
***************************************************

sum /*
*/ age1 /*
*/ audit_change_pos /*
*/ corr_vimp /*
*/ date /*
*/ date2 /*
*/ date3 /*
*/ edu /*
*/ female /*
*/ heard /*
*/ income1 /*
*/ income_noanswer /*
*/ met_ur /*
*/ doingjob_mayor /*
*/ mayor_verybad /*
*/ doingjob_natgov /*
*/ audit_change_3 /*
*/ post /*
*/ postweekwindow_1 /*
*/ postweekwindow_2 /*
*/ postweekwindow_3 /*
*/ postweekwindow_4 /*
*/ race /*
*/ unemp /*
*/ audit_change_neg /*
*/ if drop_mayorchange==0


************************************************************
*** Note on the structure of the Enumeration Area Number ***
************************************************************

* Unique eight-digit number given to an EA for record keeping and coding.
* EA demarcation was done at magisterial district level.
* To illustrate, EA number 16010073 represents the following: 
* 1 = Province
* 60 = Municipality
* 1 = EA Code distinguished in 2011 from the 2001 Census data
* 0073 = Unique EA Number within the Municipality
